export const GET_ORDER = 'GET_ORDER' //订单列表
export const GET_ORDERNUMBER = 'GET_ORDERNUMBER' //订单列表
export const DELETE_ORDERNUMBER = 'DELETE_ORDERNUMBER' //取消订单

export default {
    state:{
        obj:JSON.parse(localStorage.getItem('order'))||{},
        orderNumber:{}
    },
    mutations: {
        [GET_ORDER](state, data) {
            state.obj= data;
            localStorage.setItem('order',JSON.stringify(data))
        },
        [GET_ORDERNUMBER](state, data) {
            state.orderNumber= data;
        }
        ,
        [DELETE_ORDERNUMBER](state, id) {
            console.log(id);
            state.obj.list = state.obj.list.filter((v)=> v.orderId !== id);
            localStorage.setItem('order',JSON.stringify(state.obj))
        }
    },
    actions: {
        [GET_ORDER]({commit}, data) {

            commit(GET_ORDER, data)
        },
        [GET_ORDERNUMBER]({commit}, data) {

            commit(GET_ORDERNUMBER, data)
        }
        ,
        [DELETE_ORDERNUMBER]({commit}, data) {

            commit(DELETE_ORDERNUMBER, data)
        }
    }
}